package com.itdev.matcherapp.android.fakeservice;

import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import matcherwsservice.MatcherWSService;
import matcherwsservice.MatcherWSService_Stub;

import com.itdev.matcher.server.domain.User;
import com.pinework.pocket.util.ws.ConverterException;
import com.pinework.pocket.util.ws.ObjectStringConverter;

public class ServiceEnterprise {
	public static List<User> getPeopleNearMe(User me, float radius){
		try {
			List<User> result = new ArrayList<User>();
			MatcherWSService ws = new MatcherWSService_Stub();
			String strUser = (String) ObjectStringConverter.objectToString(me);
			String strUserList = ws.getPeopleNearMe(strUser, radius);
			result = (List<User>) ObjectStringConverter.stringToObject(strUserList);
			return result;
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return new ArrayList();
		} catch (ConverterException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return new ArrayList();
		}
	}
	
	public static boolean updateMyLocation(User user){
		try {
			MatcherWSService ws = new MatcherWSService_Stub();
			String strUser = ObjectStringConverter.objectToString(user);
			ws.updateLocation(strUser);
			return true;
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		} catch (ConverterException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
	}
}
